<!--
function linearEquation(s, x0, v0, a, eta){
	if(s==undefined){
		return null;
	}
	if(x0==undefined){
		x0 = 0;
	}
	if(v0==undefined){
		v0 = 0;
	}
	if(a==undefined){
		a = 10;
	}
	if(eta==undefined){
		eta = -0.7;
	} else if(eta>0){
		eta = -eta;
	}
	function checkValid(){
		try{
			var delta = v0*v0+2*a*(s-x0);
			if(delta>=0 && (Math.sqrt(delta)-v0)>=0){
				return true;
			} else {
				return false;
			}
		}catch (e) {
			return false;
		}
	}
	if(checkValid()){
		var x = x0;
		var v = v0;
		var isFinish = false;
		this.reset = function(){
			x = x0;
			v = v0;
			isFinish = false;
		}
		this.notFinish = function(){
			return !isFinish;
		}
		this.next = function(){
			try{
				if(a==0){
					x += v;
					if(v>0&&x>=s||v<0&&x<=s){
						x = s;
						isFinish = true;
					}
				} else {
					var t0;
					if(a>0){
						t0 = (Math.sqrt(v*v+2*a*(s-x))-v)/a;
					} else if(a<0){
						t0 = (Math.sqrt(v*v+2*a*(s-x))+v)/(-a);
					} else {
						x = s;
						isFinish = true;
					}
					if(t0<=0){
						x = s;
						isFinish = true;
					} else if(t0<1){
						var t1 = 1-t0;
						var vt = (a*t0+v)*eta;
						x = 0.5*a*t1*t1+vt*t1+s;
						v = a*t1+vt;
						if(v>-0.1&&v<0.1){
							x = s;
							isFinish = true;
						}
					} else {
						x += 0.5*a+v;
						v += a;
					}
				}
				return x;
			}catch (e) {
				x = s;
				isFinish = true;
				return x;
			}
		}
		return this;
	} else {
		return null;
	}
}
// -->